package at.dl.android.dota.adviser;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.TextView;
import at.dl.android.dota.adviser.R;

public class GalleryShopImageAdapter extends AbstractGalleryAdapter {

    private final LayoutInflater mInflater;
    
    GalleryShopImageAdapter ( Gallery gallery, ActivityWithDB avticity, int[] ids, String[] names ) {
        super(gallery,avticity,ShowShopActivity.class,ShowShopActivity.SHOP_NAME,ids,names);
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public View getView ( int position, View convertView, ViewGroup parent ) {
        final View view = mInflater.inflate(R.layout.shop_entry,parent,false);
        ImageView imageView = (ImageView) view.findViewById(R.id.img);
        imageView.setImageResource(ids[position]);
        imageVie2TextMap.put(imageView,names[position]);
        imageView.setOnClickListener(this);
        TextView t = (TextView) view.findViewById(R.id.name);
        String displayName = names[position];
        int p = displayName.indexOf(' ');
        if ( p > 0 ) {
            displayName = displayName.substring(0,p) + "...";
        }
        t.setText(displayName);
        return view;
    }
}
